package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.rmi.dgc.Lease;

/**
 * ClassName: GlobalExceptionHandler
 * Package: com.atguigu.lease.common.exception
 * Description:
 *
 * @Author 咚咚小圆帽
 * @Create 2025/2/10 17:01
 * @Version 1.0
 */
//全局异常处理器
@RestControllerAdvice
public class GlobalExceptionHandler {

    //@ResponseBody
    @ExceptionHandler(Exception.class)
    public Result handlerException(Exception e) {
        e.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler(LeaseException.class)
    public Result handlerException(LeaseException e) {
        e.printStackTrace();
        return Result.fail(e.getCode(), e.getMessage());
    }

}
